package com.company.aop;

import com.company.Website;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class DynamicProxy implements InvocationHandler {

    public DynamicProxy(Website website) {
        this.website = website;
    }

    private Website website;


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("前置处理");
        Object result = null;
        try{
            result=method.invoke(website, args);
        }catch (Exception e ){
            e.printStackTrace();
        }finally {
            System.out.println("后置处理");
        }
        return result;
    }
}
